package ink.tiptop.factory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * ***********************************************************
 * Copyright  2019 八维通科技有限公司 Inc.All rights reserved.  *
 * ***********************************************************
 * <p>
 * description: 实例工厂抽象类
 *
 * @author zjf
 * @date 2020-09-29 15:56:21
 */
abstract public class AbstractFactory<K, V> {

    private Map<K, V> map = new ConcurrentHashMap<>();

    public void register(K k, V v) {
        map.putIfAbsent(k, v);
    }

    public V unRegister(K k) {
        return map.remove(k);
    }

    public V getVal(K k) {
        return map.get(k);
    }
}